*********************************************************************************
* Title: 	Appendix															*
*********************************************************************************

* Project: 	National identity, turnout, and party preference: Evidence from Germany
* Authors: 	Matthias Mader, Maria Pesthy, Harald Schoen
* Date: 	December 2018

set scheme plotplainblind
graph set window fontface "Times New Roman"

use "Data_final.dta", clear


*********************************************************************************
* Figure A1 (distribtions of factor scores)														*
*********************************************************************************

twoway kdensity ethn_fs1 if survey == 1 || kdensity civ_fs1  if survey == 1, ///
	name(Figure_A1a, replace) legend(off)  xtitle("") text(2 .22 "Ethnocultural conception", size(large)) text(2 .81 "Civic conception", size(large) color(gs9)) yscale(range(0 3)) ylabel(0 (1) 3, labsize(large)) xlabel(, labsize(large))

twoway kdensity ethn_fs1 if survey == 6 || kdensity civ_fs1  if survey == 6, ///
	name(Figure_A1b, replace) legend(off)  xtitle("") text(2 .25 "Ethnocultural conception",  size(large)) text(2 .86 "Civic conception", size(large) color(gs9)) yscale(range(0 3)) ylabel(0 (1) 3, labsize(large)) xlabel(, labsize(large))
	
	
*********************************************************************************
* Table A2 Logistic regressions of turnout on conceptions of national identity (with and without controlling for party identification)							*
*********************************************************************************	

* Logit regressions

	*2015
	logit turnout_rs ethn_fs1 civ_fs1 pint_rs ib2.educat female ost age10 tra uni ben sec con [pweight = weight] if survey == 6 
	estimate store m1

	logit turnout_rs ethn_fs1 civ_fs1 pint_rs pi_rs_d ib2.educat female ost age10 tra uni ben sec con [pweight = weight] if survey == 6 
	estimate store m2


	*2017
	logit turnout_wkp ethn_fs1 civ_fs1 pint_wkp ib2.educat female ost age10 tra uni ben sec con [pweight = weight] if survey == 1 
	estimate store m3

	logit turnout_wkp ethn_fs1 civ_fs1 pint_wkp pi_wkp_d ib2.educat female ost age10 tra uni ben sec con [pweight = weight] if survey == 1 
	estimate store m4
	
	esttab m1 m2 m3 m4 using "Table_A2.rtf", replace 	/// 
				stats(r2_p N,fmt(2 0) labels("Pseudo-R2" "N")) ///
				cells(b(star fmt(2)) se(par fmt(2) )) ///
				nonumbers mtitles("A1""A2""B1""B2") ///
				drop(2.educat) ///
				varlabels ///
					 (ethn_fs1 "Ethnic norms" ///
					 civ_fs1 "Civic norms" ///
					 pi_rs_d "Party identification" /// 
					 pi_wkp_d "Party identification" /// 		
					 pint_rs "Political interest" ///
					 pint_wkp "Political interest" ///
					 1.educat "Low education" ///
					 3.educat "High education" ///
					 female "Female" ///
					 ost "East German" ///
					 age10 "Age (in decades)" ///
					 uni "Universalism" ///
					 tra "Traditionalism" ///
					 ben "Benevolence" ///
					 con "Conformity" ///
					 sec "Security" ///
					 _cons "Constant") ///
				order(ethn_fs1 civ_fs1 pint_rs pint_wkp pi_rs_d pi_wkp_d 1.educat 3.educat female ost age10 ben uni tra sec con _cons ) ///
				addnotes("Entries are logit coefficients with standard errors in parentheses from logistic regressions") ///
				varwidth(20) modelwidth(10)	

*********************************************************************************
* Table A3 Linear regressions of evaluations of CDU and CSU (2016/17) and Chancellor Merkel (2015 and 2016/17) on national identity conceptions							*
*********************************************************************************	

estimates clear

* OLS Regressions
	* CDU 2017
	reg  cdu8 ethn_fs1 civ_fs1 pint_wkp age10 i.educat female ost tra uni ben sec con  [pweight = weight] if survey == 1
	estimates store m1
	
	* CSU 2017			
	reg csu8 ethn_fs1 civ_fs1 pint_wkp age10 i.educat female ost tra uni ben sec con  [pweight = weight] if survey == 1
	estimates store m2
	
	* Merkel 2015
	reg w2_merkel_r ethn_fs1 civ_fs1 pint_rs age10 i.educat female ost tra uni ben sec con [pweight = weight] if survey == 6
	estimate store m3

	* Merkel 2016/17
	reg merkel8 ethn_fs1 civ_fs1 pint_wkp age10 i.educat female ost tra uni ben sec con [pweight = weight] if survey == 1
	estimate store m4

	* Table
	esttab 	m1 m2 m3 m4 using "Table_A3.rtf", replace b(2)se(2) nobaselevels ///
			stats(r2_a N,fmt(2 0) labels("Adjusted-R2" "N")) ///
			nonumbers mtitles("CDU 2016/17""CSU 2016/17""Merkel 2015""Merkel 2016/17") ///
			coeflabels(	ethn_fs1 "Ethnic conception" ///
						civ_fs1 "Civic conception" ///
						pint_wkp "Political Interest" ///
						pint_rs "Political Interest" ///
						2.educat "Middle education" ///
						3.educat "High education" ///
						female "Female" ///
						ost "East German" ///
						age10 "Age (in decades)" ///
						uni "Universalism" ///
						tra "Traditionalism" ///
						ben "Benevolence" ///
						con "Conformity" ///
						sec "Security" ///
						_cons "Constant") ///
			addnotes("Entries are coefficients from linear regressions.") ///
			


	foreach n of numlist 1/4 {
		estimates restore m`n'
		margins, dydx(ethn_fs1 civ_fs1) post
	}



*********************************************************************************
* Figure 2A Predicted probabilities of turnout while controlling for party identification		*
*********************************************************************************
	* 2015
	logit turnout_rs ethn_fs1 civ_fs1 pint_rs pi_rs_d ib2.educat female ost age10 tra uni ben sec con [pweight = weight] if survey == 6 
	estimate store m1

	*2017
	logit turnout_wkp ethn_fs1 civ_fs1 pint_wkp pi_wkp_d ib2.educat female ost age10 tra uni ben sec con [pweight = weight] if survey == 1 
	estimate store m2
	
	* Predicted probabilities 2015
		estimates restore m1
		margins, at(ethn_fs1=(0 (.1) 1)) post
		estimates store marg1

		estimates restore m1
		margins, at(civ_fs1=(0 (.1) 1)) post
		estimates store marg2
	
	* Predicted probabilities 2016/17
		estimates restore m2
		margins, at(ethn_fs1=(0 (.1) 1)) post
		estimates store marg3

		estimates restore m2
		margins, at(civ_fs1=(0 (.1) 1)) post
		estimates store marg4

* Coef-Plot
		coefplot 	(marg1, msymbol(circle) msize(large) ciopts(recast(rbar) barwidth(0.05) ) offset(.075)) ///
					(marg3, msymbol(diamond) msize(large) ciopts(recast(rbar) barwidth(0.05) ) offset(-.05)) ///
					||(marg2, msymbol(circle) msize(large) ciopts(recast(rbar) barwidth(0.05)) offset(.075)) ///
					(marg4, msymbol(diamond) msize(large) ciopts(recast(rbar) barwidth(0.05)) offset(-.05)), ///
					vertical ///
					xlabel(1 "0" 2 " " 3 " " 4 " " 5 " " 6 ".5" 7 " " 8 " " 9 " " 10 " " 11 "1" , labsize(medium) angle(0)grid) ///
					yscale(range(0.65  1.0)) ylabel(.65 (0.05) 1.0, labsize(medium)) byopts(legend(off)) ///
					ytitle("Predicted probabilities of turnout") ///
					bylabels("Ethnocultural Conception" "Civic Conception") ///
					name(Figure_A2, replace) 
					addplot 1: ,text(0.97 0.8 "2016/17", color(gray) place(right)) norescaling
					addplot 1: ,text(0.85 0.8 "2015", place(right)) norescaling

	

*********************************************************************************
* Tables A4 and A5																*
*********************************************************************************
	estimates clear
	
* Logistic regressions AV Party Identity
	*2015
	mlogit pi_rs ethn_fs1 civ_fs1 pint_rs age10 i.educat female ost tra uni ben sec con [pweight = weight] if survey == 6, baseoutcome(8)
	estimate store m1

	*2017
	mlogit pi_wkp2 ethn_fs1 civ_fs1 pint_wkp age10 i.educat female ost tra uni ben sec con [pweight = weight] if survey == 1, baseoutcome(8)
	estimate store m2
	
* Logistic Regressions AV Vote Choice (PI not controlled)
	*2015
	mlogit vote_rs ethn_fs1 civ_fs1 pint_rs age10 i.educat female ost tra uni ben sec con [pweight = weight] if survey == 6
	estimate store m3

	*2016/17
	mlogit vote_wkp  ethn_fs1 civ_fs1 pint_wkp age10 i.educat female ost tra uni ben sec con [pweight = weight] if survey == 1
	estimate store m4

* Logistic Regressions AV Vote Choice (PI controlled)
	* 2015
	mlogit vote_rs ethn_fs1 civ_fs1 ib(8).pi_rs pint_rs age10 i.educat female ost tra uni ben sec con [pweight = weight] if survey == 6
	estimate store m5
	
	* 2016/17
	mlogit vote_wkp ethn_fs1 civ_fs1 ib(8).pi_wkp pint_wkp age10 i.educat female ost tra uni ben sec con [pweight = weight] if survey == 1
	estimate store m6
	
* Tables
	* DV Party Identity
	esttab m1 m2 using "Table_A4.rtf", replace wide nogaps nonumbers ///
	mtitles("2015" "2016/17") b(2) se(2) stats(r2_p N,fmt(2 0) labels("Pseudo-R2" "N")) ///
	noomitted nobaselevels ///
	coeflabels	(ethn_fs1 "Ethnocultural" ///
				civ_fs1 "Civic" ///
				pint_rs "Political Interest" ///
				age10 "Age (Decades)" ///
				2.educat "Education: middle" ///
				3.educat "Education: high" ///
				female "Gender: Female" ///
				ost "East German Resident" ///
				tra "Traditionalism" ///
				uni "Universalism" ///
				ben "Benevolence" ///
				sec "Security" ///
				con "Conformity" ///
				_cons "Constant") ///
	addnotes("Entries are logit coefficients from multinomial logistic regressions;" ///
			"Reference category: no party")
			
	* DV Vote Choice
	esttab m3 m4 m5 m6 using "Table_A5.rtf", replace nogaps nonumbers ///
	mtitles("2015" "2016/17" "2015 (+PI)" "2016/17 (+PI)") b(2) se(2) stats(r2_p N,fmt(2 0) labels("Pseudo-R2" "N")) ///
	noomitted nobaselevels ///
	coeflabels	(ethn_fs1 "Ethnocultural" ///
				civ_fs1 "Civic" ///
				pint_rs "Political Interest" ///
				age10 "Age (Decades)" ///
				2.educat "Education: middle" ///
				3.educat "Education: high" ///
				female "Gender: Female" ///
				ost "East German Resident" ///
				tra "Traditionalism" ///
				uni "Universalism" ///
				ben "Benevolence" ///
				sec "Security" ///
				con "Conformity" ///
				1.pi_rs "PID: CDU/CSU" ///
				2.pi_rs "PID: SPD" ///
				3.pi_rs "PID: Greens" ///
				4.pi_rs "PID: Left" ///
				5.pi_rs "PID: FDP" ///
				6.pi_rs "PID: AfD" ///
				7.pi_rs "PID: Other" ///
				_cons "Constant") ///
	addnotes("Entries are logit coefficients from multinomial logistic regressions;" ///
			"Reference category: CDU/CSU")
	
/*	
*********************************************************************************
* Table 4A 																		*
*********************************************************************************	
	estimates clear
	
	* 2015
	mlogit vote_rs ethn_fs1 civ_fs1 i(8).pi_rs pint_rs age10 i.educat female ost tra uni ben sec con [pweight = weight] if survey == 6
	estimate store m1
	
	* 2016/17
	mlogit vote_wkp ethn_fs1 civ_fs1 i(8).pi_wkp pint_wkp age10 i.educat female ost tra uni ben sec con [pweight = weight] if survey == 1
	estimate store m2
	
	esttab m1 m2 using "Table_4A.rtf", replace wide nogaps nonumbers ///
	b(2) se(2) stats(r2_p N,fmt(2 0) labels("Pseudo-R2" "N")) ///
	mtitles("2015" "2016/17") noomitted ///
	drop(pint_* *pi* *educat age10 female ost tra uni ben sec con) ///
	coeflabels(	ethn_fs1 "Ethnocultural" civ_fs1 "Civic" _cons "Constant") ///
	addnotes("Entries are logit coefficients from multinomial logistic regressions;" ///
			"Additional controls not included in the table are party identity, age, education, gender, region, political interest;" ///
			"Reference category: CDU/CSU")
*/	
*********************************************************************************
* Figure 3A																		*
*********************************************************************************	

* AMEs
	* AMEs 2015
         matrix matrix2015ethn = J(6,3,.) // 3 column for lower ci, estimate, upper ci
         matrix matrix2015civ = J(6,3,.) // 3 column for lower ci, estimate, upper ci
		 foreach n of numlist 1/6 {
         estimates restore m5
         margins, dydx(ethn_fs1 civ_fs1) predict(outcome(`n')) post 
         mat r=r(table)
         matrix list r
         matrix matrix2015ethn[`n', 1] = r[1,1]
         matrix matrix2015ethn[`n', 2] = r[5,1]
         matrix matrix2015ethn[`n', 3] = r[6,1]
         matrix matrix2015civ[`n', 1] = r[1,2]
         matrix matrix2015civ[`n', 2] = r[5,2]
         matrix matrix2015civ[`n', 3] = r[6,2]
         }
	
	* AMEs 2016/17
         matrix matrix2016ethn = J(6,3,.) // 3 column for lower ci, estimate, upper ci
         matrix matrix2016civ = J(6,3,.) // 3 column for lower ci, estimate, upper ci
         foreach n of numlist 1/6 {
          estimates restore m6
          margins, dydx(ethn_fs1 civ_fs1) predict(outcome(`n')) post 
          mat r=r(table)
          matrix list r
          matrix matrix2016ethn[`n', 1] = r[1,1]
          matrix matrix2016ethn[`n', 2] = r[5,1]
          matrix matrix2016ethn[`n', 3] = r[6,1]
          matrix matrix2016civ[`n', 1] = r[1,2]
          matrix matrix2016civ[`n', 2] = r[5,2]
          matrix matrix2016civ[`n', 3] = r[6,2]
          }
		  
		matrix list matrix2015ethn
		matrix list matrix2015civ	  
		matrix list matrix2016ethn
		matrix list matrix2016civ	
	
* Coef-Plot 
	*Ethnocultural norms
	coefplot	(matrix(matrix2015ethn[,1]), ci((matrix2015ethn[,2] matrix2015ethn[,3])) msymbol(circle) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.20)) ///
				(matrix(matrix2016ethn[,1]), ci((matrix2016ethn[,2] matrix2016ethn[,3])) msymbol(diamond) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.20)) ///
				||(matrix(matrix2015civ[,1]), ci((matrix2015civ[,2] matrix2015civ[,3])) msymbol(circle) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.2)) ///
				(matrix(matrix2016civ[,1]), ci((matrix2016civ[,2] matrix2016civ[,3])) msymbol(diamond) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.2)), ///
				xlabel("-.4" (.1) ".5", labsize(large) angle(0)) ///
				xline(0, lcolor(black)) ///
				byopts(legend(off)) ///
				bylabels("Ethnocultural Conception" "Civic Conception") ///
				coeflabels(r1="CDU/CSU" r2="SPD" r3="Greens" r4="Left" r5="FDP" r6="AfD", labsize(large)) ///
				order(r6 r1 r5 r2 r3 r4) ///
				name(Figure_A3, replace)
				

*********************************************************************************
*********************************************************************************
* Subgroup Analyses																*
*********************************************************************************
*********************************************************************************

*********************************************************************************
* Figure A4: Attachment & Turnout												*
*********************************************************************************

	estimates clear
	
* Code attachment variable
	*Index
	egen attach_ind = rowmean(attach1 attach2)
	
	* Dummy
	sum attach_ind if survey == 1, det
	display r(p50)
	gen attach_ind_d2 = .
	replace attach_ind_d2 = 1 if attach_ind > r(p50) & attach_ind <= 5 & survey == 1
	replace attach_ind_d2 = 0 if attach_ind <= r(p50) & survey == 1

	sum attach_ind if survey == 6, det
	display r(p50)
	replace attach_ind_d2 = 1 if attach_ind > r(p50) & attach_ind <= 5 & survey == 6
	replace attach_ind_d2 = 0 if attach_ind <= r(p50) & attach_ind >= 0 & survey == 6
	
	tab attach_ind_d2 survey


* Logit regressions	
	* 2015
	logit turnout_rs i.attach_ind_d2##(c.ethn_fs1 c.civ_fs1) pi_rs_d pint_rs i.educat female ost age10 [pweight = weight] if survey == 6
	estimate store m1
		
	* 2016/17
	logit turnout_wkp i.attach_ind_d2##(c.ethn_fs1 c.civ_fs1) pi_wkp_d pint_wkp i.educat female ost age10 [pweight = weight] if survey == 1
	estimate store m2

	
* AMEs 
	*2015
	
		estimates restore m1
		margins, dydx(ethn_fs1 civ_fs1) at(attach_ind_d2 = 0) post  // attachment low
		estimates store marg1
	
		estimates restore m1
		margins, dydx(ethn_fs1 civ_fs1) at(attach_ind_d2 = 1) post  // attachment high
		estimates store marg2
	
	
	* 2017
		estimates restore m2 // attachment low
		margins, dydx(ethn_fs1 civ_fs1) at(attach_ind_d2 = 0) post  // attachment low
		estimates store marg3
	
		estimates restore m2 // attachment high
		margins, dydx(ethn_fs1 civ_fs1) at(attach_ind_d2 = 1) post  // attachment high
		estimates store marg4


	
	
* AME-Plots
	coefplot 	(marg1, msymbol(circle) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.20)) ///
				(marg2, msymbol(Oh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.10)) ///
				(marg3, msymbol(D) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.10)) ///
				(marg4, msymbol(Dh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.20)) ///
				 , scheme(s1mono) name(Figure_3A, replace) ///
				xtitle("", size(med)) xscale(range(-.4 .4) lcolor(gs0)) xlabel(-.4 (.1) .4) xline(0, lcolor(0)) ///
				yscale(lcolor(gs0))  ///
				coeflabels(ethn_fs1="Ethnic norms" civ_fs1="Civic norms", labsize(large)) ///
				graphregion(color(white) lwidth(large) lstyle(none)) ///
				text(0.75 -.40 "2015, Att. low", place(e) size(large)) ///
				text(0.90 -.40 "2015, Att. high", place(e) size(large)) ///
				text(1.10 -.40 "2017, Att. low", place(e) size(large)) ///
				text(1.25 -.40 "2017, Att. high", place(e) size(large)) ///
				legend(off)
	
		
*********************************************************************************
* Figure A5: Attachment & Vote Choice											*
*********************************************************************************

	estimates clear
	
* multinomial regressions	
	* 2015
	mlogit vote_rs i.attach_ind_d2##(c.ethn_fs1 c.civ_fs1) i.pi_rs pint_rs age10 i.educat female ost [pweight = weight] if survey == 6
	estimate store m1
		
	* 2016/17
	mlogit vote_wkp i.attach_ind_d2##(c.ethn_fs1 c.civ_fs1) i.pi_wkp pint_wkp age10 i.educat female ost [pweight = weight] if survey == 1
	estimate store m2
	

	
* AMEs 
	*2015
	foreach n of numlist 1/6 {
		estimates restore m1
		margins, dydx(ethn_fs1 civ_fs1) at(attach_ind_d2 = 0) predict(outcome(`n')) post  // attachment low
		estimates store marg1`n'
	}
	
	foreach n of numlist 1/6 {
		estimates restore m1
		margins, dydx(ethn_fs1 civ_fs1) at(attach_ind_d2 = 1) predict(outcome(`n')) post  // attachment high
		estimates store marg2`n'
	}
	
	* 2017
	foreach n of numlist 1/6 {
		estimates restore m2 // attachment low
		margins, dydx(ethn_fs1 civ_fs1) at(attach_ind_d2 = 0) predict(outcome(`n')) post  // attachment low
		estimates store marg3`n'
	}
	foreach n of numlist 1/6 {
		estimates restore m2 // attachment high
		margins, dydx(ethn_fs1 civ_fs1) at(attach_ind_d2 = 1) predict(outcome(`n')) post  // attachment high
		estimates store marg4`n'
	}

* AME-Plots
	*CDU/CSU
	coefplot 	(marg11, msymbol(O)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.20)) ///
				(marg21, msymbol(Oh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.15)) ///
				(marg31, msymbol(d)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.15)) ///
				(marg41, msymbol(dh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.20)) ///
				 , scheme(s1mono) ///
				xtitle("", size(med)) xscale(range(-.4 .4) lcolor(gs0)) xlabel(-.4 (.1) .4) xline(0, lcolor(0)) ///
				yscale(lcolor(gs0)) ///
				coeflabels(ethn_fs1="Ethnic norms" civ_fs1="Civic norms", labsize(small))  ///
				graphregion(color(white) lwidth(large) lstyle(none)) ///
				text(0.80 -.40 "2015, Att. high", place(e) size(small)) ///
				text(0.88 -.40 "2015, Att. low", place(e) size(small)) ///
				text(1.12 -.40 "2017, Att. high", place(e) size(small)) ///
				text(1.20 -.40 "2017, Att. low", place(e) size(small)) ///
				legend(off) title("CDU/CSU", size(small)) name(g1, replace) 
	*FDP
	coefplot 	(marg15, msymbol(O)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.20)) ///
				(marg25, msymbol(Oh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.15)) ///
				(marg35, msymbol(d)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.15)) ///
				(marg45, msymbol(dh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.20)) ///
				,scheme(s1mono) ///
				xtitle("", size(med)) xscale(range(-.4 .4) lcolor(gs0)) xlabel(-.4 (.1) .4) xline(0, lcolor(0)) ///
				yscale(lcolor(gs0)) ///
				coeflabels(ethn_fs1="Ethnic norms" civ_fs1="Civic norms", labsize(small))  ///
				graphregion(color(white) lwidth(large) lstyle(none)) ///
				legend(off) title("FDP", size(small)) name(g2, replace) 
	*SPD
	coefplot 	(marg12, msymbol(O)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.20)) ///
				(marg22, msymbol(Oh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.15)) ///
				(marg32, msymbol(d)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.15)) ///
				(marg42, msymbol(dh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.20)) ///
				,scheme(s1mono) ///
				xtitle("", size(med)) xscale(range(-.4 .4) lcolor(gs0)) xlabel(-.4 (.1) .4) xline(0, lcolor(0)) ///
				yscale(lcolor(gs0)) ///
				coeflabels(ethn_fs1="Ethnic norms" civ_fs1="Civic norms", labsize(small))  ///
				graphregion(color(white) lwidth(large) lstyle(none)) ///
				legend(off) title("SPD", size(small)) name(g3, replace) 
	*Greens
	coefplot 	(marg13, msymbol(O)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.20)) ///
				(marg23, msymbol(Oh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.15)) ///
				(marg33, msymbol(d)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.15)) ///
				(marg43, msymbol(dh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.20)) ///
				,scheme(s1mono) ///
				xtitle("", size(med)) xscale(range(-.4 .4) lcolor(gs0)) xlabel(-.4 (.1) .4) xline(0, lcolor(0)) ///
				yscale(lcolor(gs0)) ///
				coeflabels(ethn_fs1="Ethnic norms" civ_fs1="Civic norms", labsize(small))  ///
				graphregion(color(white) lwidth(large) lstyle(none)) ///
				legend(off) title("Greens", size(small)) name(g4, replace) 
	*Left
	coefplot 	(marg14, msymbol(O)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.20)) ///
				(marg24, msymbol(Oh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.15)) ///
				(marg34, msymbol(d)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.15)) ///
				(marg44, msymbol(dh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.20)) ///
				,scheme(s1mono) ///
				xtitle("", size(med)) xscale(range(-.4 .4) lcolor(gs0)) xlabel(-.4 (.1) .4) xline(0, lcolor(0)) ///
				yscale(lcolor(gs0)) ///
				coeflabels(ethn_fs1="Ethnic norms" civ_fs1="Civic norms", labsize(small))  ///
				graphregion(color(white) lwidth(large) lstyle(none)) ///
				legend(off) title("Left", size(small)) name(g5, replace)
	*AfD
	coefplot 	(marg16, msymbol(O)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.20)) ///
				(marg26, msymbol(Oh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.15)) ///
				(marg36, msymbol(d)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.15)) ///
				(marg46, msymbol(dh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.20)) ///
				,scheme(s1mono) ///
				xtitle("", size(med)) xscale(range(-.4 .4) lcolor(gs0)) xlabel(-.4 (.1) .4) xline(0, lcolor(0)) ///
				yscale(lcolor(gs0)) ///
				coeflabels(ethn_fs1="Ethnic norms" civ_fs1="Civic norms", labsize(small))  ///
				graphregion(color(white) lwidth(large) lstyle(none)) ///
				legend(off) title("AfD", size(small)) name(g6, replace) 

	
	graph combine 	g1 g2 g3 g4 g5 g6, name(Figure_5A, replace) scheme(plotplainblind) ///
					rows(3) cols(2) imargin(small) ysize(9) xsize(7) ///
					plotregion(fcolor(white)) ///
					note(	"Notes: Plotted are average marginal effects from multinomial logistic regression;" ///
							"additional controls in all models: party identification, political interest, and sociodemographics.", ///
					size(vsmall))
	


*********************************************************************************
* Figure A6: party identification												*
*********************************************************************************
	
* multinomial regressions	
	* Respondents without PID
	mlogit vote_rs ethn_fs1 civ_fs1 pint_rs age10 i.educat female ost [pweight = weight] if pi_rs == 8 & survey == 6
	estimate store m1a

	mlogit vote_wkp ethn_fs1 civ_fs1 pint_wkp age10 i.educat female ost [pweight = weight] if pi_wkp == 8 & survey == 1 
	estimate store m1b
	
	* Respondents with PID
	mlogit vote_rs ethn_fs1 civ_fs1 i.w2_pi pint_rs age10 i.educat female ost [pweight = weight] if pi_rs < 8 & survey == 6
	estimate store m2a

	mlogit vote_wkp ethn_fs1 civ_fs1 i.pi_wkp pint_wkp age10 i.educat female ost [pweight = weight] if pi_wkp < 8 & survey == 1  
	estimate store m2b
	
	
* AMEs
	* no PI
	foreach n of numlist 1/6 {
		estimates restore m1a // 2015, no PI
		margins, dydx(ethn_fs1 civ_fs1) predict(outcome(`n')) post 
		estimates store marg1a`n'
		}
	foreach n of numlist 1/6 {
		estimates restore m1b // 2017, no PI
		margins, dydx(ethn_fs1 civ_fs1) predict(outcome(`n')) post 
		estimates store marg1b`n'
		}	
		
		
	* with PI	
	foreach n of numlist 1/6 {
		estimates restore m2a // 2015 PI
		margins, dydx(ethn_fs1 civ_fs1) predict(outcome(`n')) post 
		estimates store marg2a`n'
		}
	foreach n of numlist 1/6 {
		estimates restore m2b // 2017 PI
		margins, dydx(ethn_fs1 civ_fs1) predict(outcome(`n')) post 
		estimates store marg2b`n'
		}
	
* AME-Plot
	*CDU/CSU
	coefplot	(marg1a1, msymbol(O)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.20)) ///
				(marg2a1, msymbol(Oh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.10)) ///
				(marg1b1, msymbol(d)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.10)) ///
				(marg2b1, msymbol(dh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.20)) ///
				 , scheme(s1mono) ///
				xtitle("", size(med)) xscale(range(-.4 .4) lcolor(gs0)) xlabel(-.4 (.1) .4) xline(0, lcolor(0)) ///
				yscale(lcolor(gs0)) ///
				coeflabels(ethn_fs1="Ethnic Norms" civ_fs1="Civic Norms", labsize(small))  ///
				graphregion(color(white) lwidth(large) lstyle(none)) ///
				text(0.78 -.50 "2015, no PI", place(e) size(small)) ///
				text(0.88 -.50 "2015, PI", place(e) size(small)) ///
				text(1.10 -.50 "2017, no PI", place(e) size(small)) ///
				text(1.20 -.50 "2017, PI", place(e) size(small)) ///
				legend(off) title("CDU/CSU", size(small)) name(g1, replace) 	
	
	*FDP
	coefplot 	(marg1a5, msymbol(O)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.20)) ///
				(marg2a5, msymbol(Oh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.10)) ///
				(marg1b5, msymbol(d)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.10)) ///
				(marg2b5, msymbol(dh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.20)) ///
				,scheme(s1mono) ///
				xtitle("", size(med)) xscale(range(-.4 .4) lcolor(gs0)) xlabel(-.4 (.1) .4) xline(0, lcolor(0)) ///
				yscale(lcolor(gs0)) ///
				coeflabels(ethn_fs1="Ethnic Norms" civ_fs1="Civic Norms", labsize(small))  ///
				graphregion(color(white) lwidth(large) lstyle(none)) ///
				legend(off) title("FDP", size(small)) name(g2, replace) 
	*SPD
	coefplot 	(marg1a2, msymbol(O)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.20)) ///
				(marg2a2, msymbol(Oh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.10)) ///
				(marg1b2, msymbol(d)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.10)) ///
				(marg2b2, msymbol(dh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.20)) ///
				,scheme(s1mono) ///
				xtitle("", size(med)) xscale(range(-.4 .4) lcolor(gs0)) xlabel(-.4 (.1) .4) xline(0, lcolor(0)) ///
				yscale(lcolor(gs0)) ///
				coeflabels(ethn_fs1="Ethnic Norms" civ_fs1="Civic Norms", labsize(small))  ///
				graphregion(color(white) lwidth(large) lstyle(none)) ///
				legend(off) title("SPD", size(small)) name(g3, replace) 
	*Greens
	coefplot 	(marg1a3, msymbol(O)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.20)) ///
				(marg2a3, msymbol(Oh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.10)) ///
				(marg1b3, msymbol(d)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.10)) ///
				(marg2b3, msymbol(dh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.20)) ///
				,scheme(s1mono) ///
				xtitle("", size(med)) xscale(range(-.4 .4) lcolor(gs0)) xlabel(-.4 (.1) .4) xline(0, lcolor(0)) ///
				yscale(lcolor(gs0)) ///
				coeflabels(ethn_fs1="Ethnic Norms" civ_fs1="Civic Norms", labsize(small))  ///
				graphregion(color(white) lwidth(large) lstyle(none)) ///
				legend(off) title("Greens", size(small)) name(g4, replace) 
	*Left
	coefplot 	(marg1a4, msymbol(O)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.20)) ///
				(marg2a4, msymbol(Oh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.10)) ///
				(marg1b4, msymbol(d)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.10)) ///
				(marg2b4, msymbol(dh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.20)) ///
				,scheme(s1mono) ///
				xtitle("", size(med)) xscale(range(-.4 .4) lcolor(gs0)) xlabel(-.4 (.1) .4) xline(0, lcolor(0)) ///
				yscale(lcolor(gs0)) ///
				coeflabels(ethn_fs1="Ethnic Norms" civ_fs1="Civic Norms", labsize(small))  ///
				graphregion(color(white) lwidth(large) lstyle(none)) ///
				legend(off) title("Left", size(small)) name(g5, replace)
	*AfD
	coefplot 	(marg1a6, msymbol(O)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.20)) ///
				(marg2a6, msymbol(Oh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.10)) ///
				(marg1b6, msymbol(d)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.10)) ///
				(marg2b6, msymbol(dh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.20)) ///
				,scheme(s1mono) ///
				xtitle("", size(med)) xscale(range(-.4 .4) lcolor(gs0)) xlabel(-.4 (.1) .4) xline(0, lcolor(0)) ///
				yscale(lcolor(gs0)) ///
				coeflabels(ethn_fs1="Ethnic Norms" civ_fs1="Civic Norms", labsize(small))  ///
				graphregion(color(white) lwidth(large) lstyle(none)) ///
				legend(off) title("AfD", size(small)) name(g6, replace) 

	
	graph combine 	g1 g2 g3 g4 g5 g6, name(Figure_6A, replace) scheme(plotplainblind) ///
					rows(3) cols(2) imargin(small) ysize(9) xsize(7) ///
					plotregion(fcolor(white)) ///
					note(	"Notes: Plotted are average marginal effects from multinomial logistic regression;" ///
							"additional controls in all models: political interest, sociodemographics.", ///
					size(vsmall))


*********************************************************************************
* Figure A7: Vote Choice and Sophistication										*
*********************************************************************************

* Dummy
	sum pint_wkp if survey == 1, det
	display r(p50)
	gen pint_d = .
	replace pint_d = 1 if pint_wkp >  r(p50) & pint_wkp <= 1 & survey == 1
	replace pint_d = 0 if pint_wkp <= r(p50) & survey == 1

	sum pint_rs if survey == 6, det
	display r(p50)
	replace pint_d = 1 if pint_rs >  r(p50) & pint_rs <= 1 & survey == 6
	replace pint_d = 0 if pint_rs <= r(p50) & pint_rs >= 0 & survey == 6
	
	

* multinomial regressions	
	* 2015
	mlogit vote_rs i.pint_d##(c.ethn_fs1 c.civ_fs1) i.pi_rs age10 i.educat female ost [pweight = weight] if survey == 6
	estimate store m1
		
	* 2016/17
	mlogit vote_wkp i.pint_d##(c.ethn_fs1 c.civ_fs1) i.pi_wkp age10 i.educat female ost [pweight = weight] if survey == 1
	estimate store m2
	

	
* AMEs 
	*2015
	foreach n of numlist 1/6 {
		estimates restore m1
		margins, dydx(ethn_fs1 civ_fs1) at(pint_d = 0) predict(outcome(`n')) post  // interest low
		estimates store marg1`n'
	}
	
	foreach n of numlist 1/6 {
		estimates restore m1
		margins, dydx(ethn_fs1 civ_fs1) at(pint_d = 1) predict(outcome(`n')) post  // interest high
		estimates store marg2`n'
	}
	
	* 2017
	foreach n of numlist 1/6 {
		estimates restore m2 // attachment low
		margins, dydx(ethn_fs1 civ_fs1) at(pint_d = 0) predict(outcome(`n')) post  // interest low
		estimates store marg3`n'
	}
	foreach n of numlist 1/6 {
		estimates restore m2 // attachment high
		margins, dydx(ethn_fs1 civ_fs1) at(pint_d = 1) predict(outcome(`n')) post  // interest high
		estimates store marg4`n'
	}



* AME-Plots
	*CDU/CSU
	coefplot 	(marg11, msymbol(O)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.20)) ///
				(marg21, msymbol(Oh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.15)) ///
				(marg31, msymbol(d)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.15)) ///
				(marg41, msymbol(dh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.20)) ///
				 , scheme(s1mono) ///
				xtitle("", size(med)) xscale(range(-.4 .4) lcolor(gs0)) xlabel(-.4 (.1) .4) xline(0, lcolor(0)) ///
				yscale(lcolor(gs0)) ///
				coeflabels(ethn_fs1="Ethnic norms" civ_fs1="Civic norms", labsize(small))  ///
				graphregion(color(white) lwidth(large) lstyle(none)) ///
				text(0.80 -.45 "2015, interest hi", place(e) size(small)) ///
				text(0.88 -.45 "2015, interest lo", place(e) size(small)) ///
				text(1.12 -.45 "2017, interest hi", place(e) size(small)) ///
				text(1.20 -.45 "2017, interest lo", place(e) size(small)) ///
				legend(off) title("CDU/CSU", size(small)) name(g1, replace) 
	*FDP
	coefplot 	(marg15, msymbol(O)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.20)) ///
				(marg25, msymbol(Oh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.15)) ///
				(marg35, msymbol(d)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.15)) ///
				(marg45, msymbol(dh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.20)) ///
				,scheme(s1mono) ///
				xtitle("", size(med)) xscale(range(-.4 .4) lcolor(gs0)) xlabel(-.4 (.1) .4) xline(0, lcolor(0)) ///
				yscale(lcolor(gs0)) ///
				coeflabels(ethn_fs1="Ethnic norms" civ_fs1="Civic norms", labsize(small))  ///
				graphregion(color(white) lwidth(large) lstyle(none)) ///
				legend(off) title("FDP", size(small)) name(g2, replace) 
	*SPD
	coefplot 	(marg12, msymbol(O)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.20)) ///
				(marg22, msymbol(Oh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.15)) ///
				(marg32, msymbol(d)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.15)) ///
				(marg42, msymbol(dh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.20)) ///
				,scheme(s1mono) ///
				xtitle("", size(med)) xscale(range(-.4 .4) lcolor(gs0)) xlabel(-.4 (.1) .4) xline(0, lcolor(0)) ///
				yscale(lcolor(gs0)) ///
				coeflabels(ethn_fs1="Ethnic norms" civ_fs1="Civic norms", labsize(small))  ///
				graphregion(color(white) lwidth(large) lstyle(none)) ///
				legend(off) title("SPD", size(small)) name(g3, replace) 
	*Greens
	coefplot 	(marg13, msymbol(O)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.20)) ///
				(marg23, msymbol(Oh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.15)) ///
				(marg33, msymbol(d)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.15)) ///
				(marg43, msymbol(dh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.20)) ///
				,scheme(s1mono) ///
				xtitle("", size(med)) xscale(range(-.4 .4) lcolor(gs0)) xlabel(-.4 (.1) .4) xline(0, lcolor(0)) ///
				yscale(lcolor(gs0)) ///
				coeflabels(ethn_fs1="Ethnic norms" civ_fs1="Civic norms", labsize(small))  ///
				graphregion(color(white) lwidth(large) lstyle(none)) ///
				legend(off) title("Greens", size(small)) name(g4, replace) 
	*Left
	coefplot 	(marg14, msymbol(O)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.20)) ///
				(marg24, msymbol(Oh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.15)) ///
				(marg34, msymbol(d)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.15)) ///
				(marg44, msymbol(dh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.20)) ///
				,scheme(s1mono) ///
				xtitle("", size(med)) xscale(range(-.4 .4) lcolor(gs0)) xlabel(-.4 (.1) .4) xline(0, lcolor(0)) ///
				yscale(lcolor(gs0)) ///
				coeflabels(ethn_fs1="Ethnic norms" civ_fs1="Civic norms", labsize(small))  ///
				graphregion(color(white) lwidth(large) lstyle(none)) ///
				legend(off) title("Left", size(small)) name(g5, replace)
	*AfD
	coefplot 	(marg16, msymbol(O)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.20)) ///
				(marg26, msymbol(Oh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(.15)) ///
				(marg36, msymbol(d)  msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.15)) ///
				(marg46, msymbol(dh) msize(large) ciopts(recast(rbar) barwidth(0.02)) offset(-.20)) ///
				,scheme(s1mono) ///
				xtitle("", size(med)) xscale(range(-.4 .4) lcolor(gs0)) xlabel(-.4 (.1) .4) xline(0, lcolor(0)) ///
				yscale(lcolor(gs0)) ///
				coeflabels(ethn_fs1="Ethnic norms" civ_fs1="Civic norms", labsize(small))  ///
				graphregion(color(white) lwidth(large) lstyle(none)) ///
				legend(off) title("AfD", size(small)) name(g6, replace) 

	
	graph combine 	g1 g2 g3 g4 g5 g6, name(Figure_7A, replace) scheme(plotplainblind) ///
					rows(3) cols(2) imargin(small) ysize(9) xsize(7) ///
					plotregion(fcolor(white)) ///
					note(	"Notes: Plotted are average marginal effects from multinomial logistic regression;" ///
							"additional controls in all models: party identification and sociodemographics.", ///
					size(vsmall))
